package com.crm.report.controller;

import com.crm.custinfo.domain.CustCommentRecord;
import com.crm.custinfo.service.impl.UserInfoComm;
import com.crm.report.service.ICustCommentStaticsService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.core.page.TableDataInfo;
import org.apache.commons.collections4.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * 客户备注统计
 *
 * @author Mr.Wen
 * @date 2024-02-25
 */
@RestController
@RequestMapping("/crmsys/custCommentStatics")
public class CustCommentStaticsController extends BaseController {

    @Autowired
    private UserInfoComm userInfoComm;
    @Autowired
    private ICustCommentStaticsService commentRecordService;
    /**
     *   客户备注统计 报表
     */
    @GetMapping("/getCustCommentStaticslist")
    public TableDataInfo getCustCommentStaticslist(CustCommentRecord custCommentRecord)
    {
        Map<String, Object> inParams = custCommentRecord.getParams();
        SysDept sysDept=new SysDept();
        Long deptId= MapUtils.getLongValue(inParams,"deptId",-1);
        deptId= deptId==-1 ? getDeptId() : deptId;
        sysDept.setDeptId(deptId);
        Long[] orgIds=userInfoComm.getSysDepts(sysDept);
        inParams.put("deptIds",orgIds);
        custCommentRecord.setParams(inParams);
        List<Map<String,Object>> list=commentRecordService.custCommentRecordStatics(custCommentRecord);
        return getDataTable(list);
    }
}
